package com.epower.bo.epower.commons;

import java.util.Map;

public class Result implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	private Integer resultCode;
	private String message;
	private Map<String, ? extends Object> resultMap;
	public final static boolean SUCCESS_TRUE = true;
	public final static boolean SUCCESS_FALSE = false;
	public final static int RESULTCODE_NORMAL = 0; // 正常
	public final static int RESULTCODE_REQUEST_FAILURE = -1; // 请求失败
	public final static int RESULTCODE_TOKENVALIDATE_FAILURE = -2; // 签名验证失败
	public final static int RESULTCODE_PARAMETER_ILLEGAL = -3; // 参数非法

	public final static Integer isSuccess = 1;

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Integer getResultCode() {
		return resultCode;
	}

	public void setResultCode(Integer resultCode) {
		this.resultCode = resultCode;
	}

	public boolean isOK() {
		if (this.resultCode.equals(Result.isSuccess)) {
			return true;
		} else {
			return false;
		}
	}

	public Map<String, ? extends Object> getResultMap() {
		return resultMap;
	}

	public void setResultMap(Map<String, ? extends Object> resultMap) {
		this.resultMap = resultMap;
	}

	public static Result succResult() {
		Result r = new Result();
		r.setResultCode(Result.isSuccess);
		return r;
	}

	public static Result errorResult(int resultCode, String message) {
		Result r = new Result();
		r.setResultCode(resultCode);
		r.setMessage(message);
		return r;
	}

	public static Result commonResult(String message) {
		Result r = new Result();
		r.setResultCode(Result.isSuccess);
		r.setMessage(message);
		return r;
	}

}
